package cn.ztuo.bitrade.controller.member;

import cn.ztuo.bitrade.annotation.AccessLog;
import cn.ztuo.bitrade.constant.AdminModule;
import cn.ztuo.bitrade.controller.common.BaseAdminController;
import cn.ztuo.bitrade.entity.MemberVip;
import cn.ztuo.bitrade.service.LocaleMessageSourceService;
import cn.ztuo.bitrade.service.MemberService;
import cn.ztuo.bitrade.service.MemberVipService;
import cn.ztuo.bitrade.util.MessageResult;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/memberVip")
public class MemberVipController extends BaseAdminController {

    @Autowired
    private MemberVipService memberVipService;
    @Autowired
    private MemberService memberService;
    @Autowired
    private LocaleMessageSourceService messageSource;


    @RequiresPermissions("memberVip:all")
    @PostMapping("all")
    @AccessLog(module = AdminModule.MEMBER, operation = "所有等级配置")
    public MessageResult all() {
        List<MemberVip> all = memberVipService.findAll();
        if (all != null && all.size() > 0) {
            return success(all);
        }
        return error(messageSource.getMessage("REQUEST_FAILED"));
    }
}
